package pl.radiomaryja.softcognito;

import android.content.SharedPreferences;

public class AudioItem extends PodcastItem {

	public static final String PREFS_NAME = "Files";
	private String date = "";
	private String filename = "";
	
	protected AudioItem(String title, String link) 
	{	
		super(cleanTitle(title), link);
		setCleanDate(title);
		setFilename();
	}
	
	
	private static String cleanTitle(String title) {
		return title.substring(0,title.length()-13);
	}
	
	public void setCleanDate(String attTitle) {		
		setDate(attTitle.substring(attTitle.length()-11, attTitle.length()-1));
	}	
	
	public void setFilename() {
		SharedPreferences fileName = getSharedPreferences(PREFS_NAME, 0);
		filename = fileName.getString(getLink(), "");
	}
	
	public void setNewFilename(String nfilename) {
		SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putString(getLink(), nfilename);
		editor.commit();
		filename = nfilename;
	}	
	
	public void setDate(String attDate) {
		date = attDate;
	}
	
	public String getDate() {
		return date;
	}
	
	public String getFilename()
	{	
		return filename;
	}
	
}
